package com.shicai.mybatis.demos;

import com.shicai.mybatis.beans.Employee;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis.xml";
        InputStream resourceAsStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = build.openSession();
        Object o = sqlSession.selectOne("feichangbang.sql1", 1);
        Employee employee = (Employee) o;
        //System.out.println(employee);

        Employee e = new com.shicai.mybatis.beans.Employee();
        e.setId(1);
        e.setLastName("To");
        e.setGender("male");
        e.setEmail("Tom@163.com");
        System.out.println(e);

    }
}
